<include file="../header" />
<body class="J_scroll_fixed">
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script charset="utf-8" src="http://map.qq.com/api/js?v=2.exp&key=FO5BZ-2AC2G-ACAQV-I5BD3-YX65K-76BUB"></script>
    <script src="http://open.map.qq.com/apifiles/v1.0/app.js?v=1.0.131203.1" type="text/javascript"></script>
    <script type="text/javascript">
      
        function initialize(){

            $('select[name=shopId]').attr("disabled","disabled"); 
            $('select[name=type]').attr("disabled","disabled"); 
        }
    $(function() {
        //初始化
        initialize();
        
        $('button#send').click(function(){
            var to = $('input[name=to]').val();
            var commission = $('input[name=commission]').val();
            var rate = $('input[name=rate]').val();
            //正则判断是否为数字
            if(!/^\d+$/.test(to)||to<=0) {
                layer.msg('提成上限应为正整数!');
                return false;
            }
            //验证有1-3位小数的正实数
            if(!/^[0-9]+(.[0-9]{1,3})?$/.test(commission)||commission==null||commission==''){
                layer.msg('提成数额应为1-3位小数的正实数!');
                return false;
            }
            //验证有1-3位小数的正实数
            if(!/^[0-9]+(.[0-9]{1,3})?$/.test(rate)||rate==null||rate==''){
                layer.msg('提成比率应为1-3位小数的正实数!');
                return false;
            }
            $('form').submit();
        });

    });
</script>
	<div class="wrap jj">
		<div class="common-form">
			<form method="post" class="form-horizontal J_ajaxForm" action="{:U('commission/edit_post')}">
				<fieldset>
					<div class="control-group">
						<label class="control-label">店铺：</label>
						<div class="controls">
							{:getShopSelectHtml($shopId)}
						</div>
					</div>
                                    <div class="control-group">
						<label class="control-label">提成模板下限：</label>
						<div class="controls">
                                                    <input type="text" class="input" name="from" value="{$comm.from}" readonly="true">
						</div>
					</div>
                                        <div class="control-group">
						<label class="control-label">提成模板上限：</label>
						<div class="controls">
                                                    <input type="text" class="input" name="to" value="{$comm.to}">
						</div>
					</div>
                                        <div class="control-group">
						<label class="control-label">提成类型:</label>
						<div class="controls" >
							{:getEnumSelectWidget($type,'type',$comm['type'])}
						</div>
					</div>
                                    <div class="control-group">
						<label class="control-label">提成数额：</label>
						<div class="controls">
                                                    <input type="text" class="input" name="commission" value="{$comm.commission}">
						</div>
					</div>
                                    <div class="control-group">
						<label class="control-label">提成比率：</label>
						<div class="controls">
                                                    <input type="text" class="input" name="rate" value="{$comm.rate}"  placeholder="3.0">
						</div>
					</div>
				</fieldset>
				<div class="form-actions">
                                    <input name='id' type='hidden' value="{$comm.commission_id}"/>
					<button type="" class="btn btn-primary" id="send">更新</button>
					<a class="btn" href="__URL__">返回</a>
				</div>
			</form>
		</div>
	</div>
	<script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>